/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.risk.mapper;


import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.koron.risk.bean.SourceQueryBean;
import com.koron.risk.domain.HazardSourceGridRelation;
import com.koron.risk.domain.LocalHazardSource;

public interface HazardSourceDistributeMapper {
	Integer batchInsert(@Param("beanList")List<HazardSourceGridRelation> beanList);

	@Delete("delete from hazardsource_grid_relation where corp_Code=#{corpCode} and grid_code=#{gridCode} and local_hazard_code=#{lhsCode}")
	Integer deleteByCode(@Param("corpCode")String corpCode,@Param("gridCode")String gridCode,@Param("lhsCode")String lhsCode);

	@Update("update hazardsource_grid_relation set hazard_number=#{num},manager_code=#{managerCode},manager_name=#{managerName},update_user=#{updateUser},update_time=sysdate() where grid_code=#{gridCode} and local_hazard_code=#{code}")
	Integer updateNum(@Param("code") String code,@Param("gridCode") String gridCode, @Param("num") int num,@Param("managerCode") String managerCode,
					  @Param("managerName") String managerName,@Param("updateUser") String updateUser);

	@Select("select count(*) from hazardsource_grid_relation where corp_Code=#{corpCode} and grid_code=#{gridCode} and local_hazard_code=#{lhsCode}")
	Integer addCount(@Param("corpCode")String corpCode,@Param("gridCode")String gridCode,@Param("lhsCode")String lhsCode);

	Integer count(SourceQueryBean queryBean);

	Integer irrelevantCount (SourceQueryBean queryBean);

	List<LocalHazardSource> irrelevantList(SourceQueryBean queryBean);

	Integer countAll(SourceQueryBean queryBean);

	List<LocalHazardSource> childList(SourceQueryBean queryBean);

	List<LocalHazardSource> list(SourceQueryBean queryBean);

	@Select("select count(*) from hazardsource_grid_relation where corp_Code=#{corpCode} and grid_code=#{gridCode}")
	Integer countByCorpAndGrid(@Param("corpCode")String corpCode,@Param("gridCode")String gridCode);

	List<HazardSourceGridRelation> query(@Param("code") String code,@Param("gridCode") String gridCode,@Param("corpCode") String corpCode);

    Integer countAllByGrid(SourceQueryBean queryBean);

	List<LocalHazardSource> childListByGrid(SourceQueryBean queryBean);
}
